﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using DawnTools;
public class UGit :EditorWindow
{
	[MenuItem("UGit/Window")]
    static void Add()
    {
    	//创建窗口
		Rect  wr = new Rect (0,0,500,300);
        UGit window = (UGit)EditorWindow.GetWindow(typeof (UGit),true,"UGit");	
		window.Show();
		cmd.RunCmd("cd "+ Application.dataPath.Replace("/Assets",""));
    }
    static Cmd cmd = new Cmd();
    private string commitText = "";
    void OnGUI()
    {
    	commitText = EditorGUILayout.TextField("Comments:","No Comments",GUILayout.Height(100));
    	if(GUILayout.Button("提交到本地",GUILayout.Height(30)))
    	{
    		Debug.Log(cmd.RunCmd("git add ."));
    		Debug.Log(cmd.RunCmd("git commit -m \""+commitText+"\""));
    	}
    	if(GUILayout.Button("从云端同步",GUILayout.Height(30)))
    	{
    		Debug.Log(cmd.RunCmd("git pull"));
    	}
    	if(GUILayout.Button("尝试提交到云端",GUILayout.Height(30)))
    	{
    		Debug.Log(cmd.RunCmd("git push"));
    	}
    }
    void OnInspectorUpdate()
	{
	   //这里开启窗口的重绘，不然窗口信息不会刷新
	   this.Repaint();
	}
}
